package com.zang.everyday;

/**
 * @Author: ZVerify
 * @Description: https://leetcode.cn/problems/maximum-ascending-subarray-sum/
 * @DateTime: 2022/10/7 10:54
 **/

public class 最大升序子数组和 {

    public int maxAscendingSum(int[] nums) {
        int ans = 0, sum = 0, n = nums.length;
        for (int i = 0; i < n; i++) {
            if (i == 0 || nums[i] > nums[i - 1]) {
                sum += nums[i];
            } else {
                sum = nums[i];
            }
            ans = Math.max(ans, sum);
        }
        return ans;
    }
}